home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11859 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  48 lines

  1. Path: inforamp.net!ts16-02
  2. From: rmorin@inforamp.net (Randy Charles Morin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Persistent Objects
  5. Date: Sat, 16 Mar 96 18:53:59 GMT
  6. Organization: MiddleWorld SoftWare
  7. Message-ID: <4if2op$578@sam.inforamp.net>
  8. References: <4i50ja$2lu@atlantis.cc.uwf.edu>
  9. NNTP-Posting-Host: ts16-02.tor.inforamp.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <4i50ja$2lu@atlantis.cc.uwf.edu>,
  13.    dwelch@news.uwf.edu (dale welch) wrote:
  14. >
  15. >    This may be a really trivial thing, but i am doing a project
  16. > that requires persistent objects to be used, and was wondering if
  17. > there was a good example of this kind of implementation. I know the
  18. > basic theory behind the problem, but to see a working example of
  19. > a basic program, no matter what its size would really be helpful.
  20. > Well, thanks for any suggestions or pointers...
  21. >
  22. >                        dale
  23.  
  24. class PersistentObject 
  25. {
  26. private:
  27.     int i;
  28. public:
  29.     PersistentObject();
  30.     ~PersistentObject();    
  31. };
  32.  
  33. PersistentObject::PersistentObject()
  34. {
  35.     ifstream is(FILENAME.EXT);
  36.     is >> i;
  37. }
  38.  
  39. PersistentObject::~PersistentObject()
  40. {
  41.     ofstream os(FILENAME.EXT);
  42.     os << i;
  43. }
  44.  
  45. A very simplistic example.
  46.  
  47. Agrivar
  48.